<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 10] Long</TITLE>
<META NAME="author" CONTENT="Mark Grand">
<META NAME="date" CONTENT="Fri Aug  8 15:25:10 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="java">
<META NAME="title" CONTENT="Java Language Reference">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java Language Reference" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch10_10.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 10<br>The java.lang Package</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch10_12.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=refnamediv>
<H1>Long</H1>

<H2>Name</H2>

Long

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.81">Synopsis</A></h2>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Class Name:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.lang.Long</tt>

<p>
<DT CLASS=varlistentry>Superclass:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.lang.Number</tt>

<p>
<DT CLASS=varlistentry>Immediate Subclasses:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Interfaces Implemented:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Availability:<br>
<DD>

<P CLASS=para>
JDK 1.0 or later</DL>
</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.82">Description</A></h2>

<P CLASS=para>
<A NAME="MAN.LONG.1"></A>The <tt CLASS=literal>Long</tt> class provides an object wrapper
for a <tt CLASS=literal>long</tt> value. This is useful when you need
to treat a <tt CLASS=literal>long</tt> value as an object. For example,
there are a number of utility methods that take a reference to an
<tt CLASS=literal>Object</tt> as one of their arguments. You cannot
specify a <tt CLASS=literal>long</tt> value for one of these arguments,
but you can provide a reference to a <tt CLASS=literal>Long</tt> object
that encapsulates the <tt CLASS=literal>long</tt> value. Furthermore,
as of JDK 1.1, the <tt CLASS=literal>Long</tt> class is necessary to 
support the Reflection API and class literals.

<P CLASS=para>
The <tt CLASS=literal>Long</tt> class also provides a number of
utility methods for converting <tt CLASS=literal>long</tt> values to
other primitive types and for converting <tt CLASS=literal>long</tt> values
to strings and vice versa.

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.83">Class Summary</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public final class java.lang.Long extends java.lang.Number {
    // Constants
    public static final long MIN_VALUE;
    public static final long MAX_VALUE;
    public final static Class TYPE;                    // New in 1.1
    // Constructors
    public Long(long value);
    public Long(String s);
    // Class Methods
    public static Long getLong(String nm);
    public static Long getLong(String nm, long val);
    public static Long getLong(String nm, Long val);
    public static long parseLong(String s);
    public static long parseLong(String s, int radix);
    public static String toBinaryString(long i);
    public static String toHexString(long i);
    public static String toOctalString(long i);
    public static String toString(long i);
    public static String toString(long i, int radix);
    public static Long valueOf(String s);
    public static Long valueOf(String s, int radix);
    // Instance Methods
    public byte byteValue();                           // New in 1.1
    public double doubleValue();
    public boolean equals(Object obj);
    public float floatValue();
    public int hashCode();
    public int intValue();
    public long longValue();
    public short shortValue();                         // New in 1.1
    public String toString();
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.84">Constants</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.209">MAX_VALUE</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.223"><tt CLASS=literal>public static final long MAX_VALUE = 0x7fffffffffffffffL</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The largest value that can be represented by a <tt CLASS=literal>long</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.210">MIN_VALUE</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.224"><tt CLASS=literal>public static final long MIN_VALUE = 0x8000000000000000L</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The smallest value that can be represented by a <tt CLASS=literal>long</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.211">TYPE</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.225"><tt CLASS=literal>public static final Class TYPE </tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Availability<br>
<DD>

<P CLASS=para>
New as of JDK 1.1

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>Class</tt> object that represents the type
<tt CLASS=literal>long</tt>.
It is always true that <tt CLASS=literal>Long.TYPE</tt> 
<tt CLASS=literal>==</tt> <tt CLASS=literal>long.class</tt>.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.85">Constructors</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.212">Long</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.226"><tt CLASS=literal>public Long(long value)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>value</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>long</tt> value to be encapsulated
by this object.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Creates a <tt CLASS=literal>Long</tt> object with the specified
<tt CLASS=literal>long</tt> value.</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.227"><tt CLASS=literal>public Long(String s) throws NumberFormatException</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The string to be made into a <tt CLASS=literal>Long</tt>
object.</DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>NumberFormatException</tt><br>
<DD>

<P CLASS=para>
If the sequence of characters in the given <tt CLASS=literal>String</tt>
does not form a valid <tt CLASS=literal>long</tt> literal.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>Long</tt> object with the value
specified by the given string. The string should consist of one or
more digit characters. The digit characters can be preceded by a
single `<tt CLASS=literal>-</tt>' character. If the string contains any other characters, the
constructor throws a <tt CLASS=literal>NumberFormatException</tt>.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.86">Class Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.213">getLong</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.228"><tt CLASS=literal>public static Integer getLong(String nm)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>nm</tt><br>
<DD>

<P CLASS=para>
The name of a system property.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of the system property as a <tt CLASS=literal>Long</tt> object
or a <tt CLASS=literal>Long</tt> object with the value 0 if the named
property does not exist or cannot be parsed.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method retrieves the value of the named system property
and returns it as a <tt CLASS=literal>Long</tt> object. The method obtains
the value of the system property as a <tt CLASS=literal>String</tt>
using <tt CLASS=literal>System.getProperty()</tt>.

<P CLASS=para>
If the value of the property begins with <tt CLASS=literal>0x</tt>
or <tt CLASS=literal>#</tt> and is not followed by a minus sign, the
rest of the value is parsed as a hexadecimal integer. If the value
begins with <tt CLASS=literal>0</tt>, it's parsed as an octal integer;
otherwise it's parsed as a decimal integer.</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.229"><tt CLASS=literal>public static Long getLong(String nm, long val)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>nm</tt><br>
<DD>

<P CLASS=para>
The name of a system property.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>val</tt><br>
<DD>

<P CLASS=para>
A default value for the property.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of the system property as a <tt CLASS=literal>Long</tt> object
or a <tt CLASS=literal>Long</tt> object with the value <tt CLASS=literal>val</tt>
if the named property does not exist or cannot be parsed.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method retrieves the value of the named system property
and returns it as a <tt CLASS=literal>Long</tt> object. The method obtains
the value of the system property as a <tt CLASS=literal>String</tt>
using <tt CLASS=literal>System.getProperty()</tt>.

<P CLASS=para>
If the value of the property begins with <tt CLASS=literal>0x</tt> or
<tt CLASS=literal>#</tt> and is not followed by a minus sign, the rest of
the value is parsed as a hexadecimal integer. If the value begins with
<tt CLASS=literal>0</tt>, it's parsed as an octal integer; otherwise it's
parsed as a decimal integer.</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.230"><tt CLASS=literal>public static Long getLong(String nm, Long val)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>nm</tt><br>
<DD>

<P CLASS=para>
The name of a system property.
 

<p>
<DT CLASS=varlistentry><tt CLASS=literal>val</tt><br>
<DD>

<P CLASS=para>
A default value for the property.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of the system property as a <tt CLASS=literal>Long</tt> object,
or the <tt CLASS=literal>Long</tt> object <tt CLASS=literal>val</tt> if
the named property does not exist or cannot be parsed.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method retrieves the value of the named system property
and returns it as a <tt CLASS=literal>Long</tt> object. The method obtains
the value of the system property as a <tt CLASS=literal>String</tt>
using <tt CLASS=literal>System.getProperty()</tt>.

<P CLASS=para>
If the value of the property begins with <tt CLASS=literal>0x</tt> or
<tt CLASS=literal>#</tt> and is not followed by a minus sign, the rest of
the value is parsed as a hexadecimal integer. If the value begins with
<tt CLASS=literal>0</tt>, it's parsed as an octal integer; otherwise it's
parsed as a decimal integer.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.214">parseLong</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.231"><DIV CLASS=screen> <P> <PRE> public static long parseLong(String s) throws NumberFormatException </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>String</tt> to be converted to
a <tt CLASS=literal>long</tt> value.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The numeric value of the <tt CLASS=literal>long</tt> represented
by the <tt CLASS=literal>String</tt> object.

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>NumberFormatException</tt><br>
<DD>

<P CLASS=para>
If the <tt CLASS=literal>String</tt> does not contain
a valid representation of a <tt CLASS=literal>long</tt> value.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the numeric value of the <tt CLASS=literal>long</tt>
represented by the contents of the given <tt CLASS=literal>String</tt>
object. The <tt CLASS=literal>String</tt> must contain only decimal
digits, except that the first character may be a minus sign.</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.232"><DIV CLASS=screen> <P> <PRE> public static long parseLong(String s, int radix) throws NumberFormatException </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>String</tt> to be converted to
a <tt CLASS=literal>long</tt> value.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>radix</tt><br>
<DD>

<P CLASS=para>
The radix used in interpreting the characters in
the <tt CLASS=literal>String</tt> as digits. It must be in the
range <tt CLASS=literal>Character.MIN_RADIX</tt> to
<tt CLASS=literal>Character.MAX_RADIX</tt>.
If <tt CLASS=literal>radix</tt> is in the range 2 through 10,
only characters for which the <tt CLASS=literal>Character.isDigit()</tt>
method returns <tt CLASS=literal>true</tt> are considered valid digits.
If <tt CLASS=literal>radix</tt> is in the range 11 through 36,
characters in the ranges
`A' through `Z' and `a' through `z' may be considered valid digits.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The numeric value of the <tt CLASS=literal>long</tt> represented
by the <tt CLASS=literal>String</tt> object in the specified radix.

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>NumberFormatException</tt><br>
<DD>

<P CLASS=para>
If the <tt CLASS=literal>String</tt> does not contain
a valid representation of a <tt CLASS=literal>long</tt> or <tt CLASS=literal>radix</tt>
is not in the appropriate range.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the numeric value of the <tt CLASS=literal>long</tt>
represented by the contents of the given <tt CLASS=literal>String</tt>
object in the specified radix. The <tt CLASS=literal>String</tt> must
contain only valid digits of the specified radix, except that the
first character may be a minus sign. The digits are parsed in the
specified radix to produce the numeric value.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.215">toBinaryString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.233"><tt CLASS=literal>public static String toBinaryString(long value)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>value</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>long</tt> value to be converted
to a string.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A string that contains the binary representation of the given
value.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains the representation of the given value as an unsigned binary
number. To convert the given value to an unsigned quantity, the
method simply uses the value as if it were not negative. In other
words, if the given value is negative, the method adds 2^64 to it.
Otherwise the value is used as it is.

<P CLASS=para>
The string returned by this method contains a sequence of
one or more `0' and `1' characters. The method returns "0" if its
argument is <tt CLASS=literal>0</tt>. Otherwise, the string returned
by this method begins with `1'.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.216">toHexString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.234"><tt CLASS=literal>public static String toHexString(long value)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>value</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>long</tt> value to be converted
to a string.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A string that contains the hexadecimal representation of the
given value.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains the representation of the given value as an unsigned hexadecimal
number. To convert the given value to an unsigned quantity, the
method simply uses the value as if it were not negative. In other
words, if the given value is negative, the method adds 2^64 to it.
Otherwise the value is used as it is.

<P CLASS=para>
The string returned by this method contains a sequence of
one or more of the characters `0', `1', `2', `3', `4', `5', `6',
`7', `8', `9', `a', `b', `c', `d', `e', and `f'.
The method returns "0" if its argument is
<tt CLASS=literal>0</tt>. Otherwise, the string returned by this method
does not begin with `0'.

<P CLASS=para>
To produce a string that contains upper- instead
of lowercase letters, use the <tt CLASS=literal>String.toUpperCase()</tt>
method.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.217">toOctalString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.235"><tt CLASS=literal>public static String toOctalString(long value)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>value</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>long</tt> value to be converted
to a string.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A string that contains the octal representation of the given
value.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains a representation of the given value as an unsigned octal
number. To convert the given value to an unsigned quantity, the
method simply uses the value as if it were not negative. In other
words, if the given value is negative, the method adds 2^64 to it.
Otherwise the value is used as it is.

<P CLASS=para>
The string returned by this method contains a sequence of
one or more of the characters `0', `1', `2', `3', `4', `5', `6',
and `7'. The method returns "0" if its
argument is <tt CLASS=literal>0</tt>. Otherwise,
the string returned by this method does not begin with `0'.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.218">toString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.236"><tt CLASS=literal>public static String toString(long i)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>i</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>long</tt> value to be converted
to a string.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The string representation of the given value.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains the decimal representation of the given value.

<P CLASS=para>
This method returns a string that begins with `<tt CLASS=literal>-</tt>' if the given
value is negative. The rest of the string is a sequence of one or
more of the characters `0', `1', `2', `3', `4', `5', `6', `7', `8',
and `9'. This method returns "0" if its argument is <tt CLASS=literal>0</tt>.
Otherwise, the string returned by this method does not begin with
"0" or "<tt CLASS=literal>-</tt>0".</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.237"><tt CLASS=literal>public static String toString(long i, int radix)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>i</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>long</tt> value to be converted
to a string.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>radix</tt><br>
<DD>

<P CLASS=para>
The radix used in converting the value to a string.
This value must be in the range <tt CLASS=literal>Character.MIN_RADIX</tt>
to <tt CLASS=literal>Character.MAX_RADIX</tt>.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The string representation of the given value in the specified
radix.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains the representation of the given value in the specified
radix.

<P CLASS=para>
This method returns a string that begins with`<tt CLASS=literal>-</tt>'  if the given
value is negative. The rest of the string is a sequence of one or
more characters that represent the magnitude of the given value.
The characters that can appear in the sequence are determined by
the value of <tt CLASS=literal>radix</tt>. If <I CLASS=emphasis>N</I>
is the value of <tt CLASS=literal>radix</tt>, the first <I CLASS=emphasis>N</I>
characters on the following line can appear in the sequence:

<DIV CLASS=screen>
<P>
<PRE>
0123456789abcdefghijklmnopqrstuvwxyz
</PRE>
</DIV>

<P CLASS=para>
The method does not verify that <tt CLASS=literal>radix</tt> is
in the proper range. If <tt CLASS=literal>radix</tt> is less than <tt CLASS=literal>Character.MIN_RADIX</tt>
or greater than <tt CLASS=literal>Character.MAX_RADIX</tt>, the value
10 is used instead of the given value.

<P CLASS=para>
This method returns "0" if its argument is <tt CLASS=literal>0</tt>.
Otherwise, the string returned by this method does not begin with
"0" or "<tt CLASS=literal>-</tt>0".</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.219">valueOf</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.238"><DIV CLASS=screen> <P> <PRE> public static Long valueOf(String s) throws NumberFormatException </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The string to be made into a <tt CLASS=literal>Long</tt>
object.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>Long</tt> object constructed from the string.

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>NumberFormatException</tt><br>
<DD>

<P CLASS=para>
If the <tt CLASS=literal>String</tt> does not contain
a valid representation of a <tt CLASS=literal>long</tt>.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>Long</tt> object with the value
specified by the given string. The string should consist of one or more
digit characters. The digit characters can be preceded by a single <tt CLASS=literal>-</tt>
character. If the string contains any other characters, the method
throws a <tt CLASS=literal>NumberFormatException</tt>.</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.239"><DIV CLASS=screen> <P> <PRE> public static Long valueOf(String s, int radix) throws NumberFormatException </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The string to be made into a <tt CLASS=literal>Long</tt>
object.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>radix</tt><br>
<DD>

<P CLASS=para>
The radix used in converting the string to a value.
This value must be in the range <tt CLASS=literal>Character.MIN_RADIX</tt>
to <tt CLASS=literal>Character.MAX_RADIX</tt>.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>Long</tt> object constructed from the string.

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>NumberFormatException</tt><br>
<DD>

<P CLASS=para>
If the <tt CLASS=literal>String</tt> does not contain
a valid representation of a <tt CLASS=literal>long</tt>.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>Long</tt> object with the value
specified by the given string in the specified radix. The string
should consist of one or more digit characters or characters in
the range `A' to `Z' or `a' to `z' that are considered digits
in the given radix. The digit characters can be preceded by
a single `<tt CLASS=literal>-</tt>' character. If the string contains any other
characters, the method throws a <tt CLASS=literal>NumberFormatException</tt>.

<P CLASS=para>
The method does not verify that <tt CLASS=literal>radix</tt> is
in the proper range. If <tt CLASS=literal>radix</tt> is less than <tt CLASS=literal>Character.MIN_RADIX</tt>
or greater than <tt CLASS=literal>Character.MAX_RADIX</tt>, the value
10 is used instead of the given value.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.87">Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.220">byteValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.240"><tt CLASS=literal>public byte byteValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Availability<br>
<DD>

<P CLASS=para>
New as of JDK 1.1

<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>byte</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.byteValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as a <tt CLASS=literal>byte</tt>.
The high order bits of the value are discarded.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.221">doubleValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.241"><tt CLASS=literal>public double doubleValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>double</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.doubleValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as a <tt CLASS=literal>double</tt>.
Rounding may occur.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.222">equals</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.242"><tt CLASS=literal>public boolean equals(Object obj)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>obj</tt><br>
<DD>

<P CLASS=para>
The object to be compared with this object.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if the objects are equal; <tt CLASS=literal>false</tt>
if they are not.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.equals()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns <tt CLASS=literal>true</tt> if <tt CLASS=literal>obj</tt>
is an instance of <tt CLASS=literal>Long</tt> and it contains the same
value as the object this method is associated with.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.223">floatValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.243"><tt CLASS=literal>public float floatValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>float</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.floatValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as a <tt CLASS=literal>float</tt>.
Rounding may occur.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.224">hashCode</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.244"><tt CLASS=literal>public int hashCode()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A hashcode based on the <tt CLASS=literal>long</tt> value of
the object.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.hashCode()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a hashcode computed from the value of
this object. More specifically, the result is the exclusive OR of
the two halves of the <tt CLASS=literal>long</tt> value represented
by the object. If <tt CLASS=literal>value</tt> is the value of the object,
the method returns a result equivalent to the following expression:

<DIV CLASS=screen>
<P>
<PRE>
(int)(value^(value&gt;&gt;&gt;32))
</PRE>
</DIV>

</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.225">intValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.245"><tt CLASS=literal>public int intValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as an <tt CLASS=literal>int</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.intValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as an <tt CLASS=literal>int</tt>.
The high-order bits of the value are discarded.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.226">longValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.246"><tt CLASS=literal>public long longValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>long</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.longValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as a <tt CLASS=literal>long</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.227">shortValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.247"><tt CLASS=literal>public short shortValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Availability<br>
<DD>

<P CLASS=para>
New as of JDK 1.1

<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>short</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.shortValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as a <tt CLASS=literal>short</tt>.
The high-order bits of the value are discarded.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch10-REFSECT2-AUTOID.228">toString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch10-REFSECT3-AUTOID.248"><tt CLASS=literal>public String toString()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The string representation of the value of this object.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.toString()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains the decimal representation of the value of this object.

<P CLASS=para>
This method returns a string that begins with `<tt CLASS=literal>-</tt>' if the value
is negative. The rest of the string is a sequence of one or more
of the characters `0', `1', `2', `3', `4', `5', `6', `7', `8', and
`9'. This method returns "0" if the value of
the object is <tt CLASS=literal>0</tt>.
Otherwise, the string returned by this method does not begin with
"0" or "<tt CLASS=literal>-</tt>0".</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.88">Inherited Methods</A></h2>

<DIV CLASS=informaltable>
<P>
<TABLE CLASS=INFORMALTABLE>
<TR CLASS=row>
<TH ALIGN="left">

<P CLASS=para>
Method</TH>
<TH ALIGN="left">

<P CLASS=para>
Inherited From</TH>
<TH ALIGN="left">

<P CLASS=para>
Method</TH>
<TH ALIGN="left">

<P CLASS=para>
Inherited From</TH>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>clone()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>finalize()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>getClass()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>notify()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>notifyAll()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>wait()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>wait(long)</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>wait(long, int)</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
</TABLE>
<P>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch10-REFSECT1-AUTOID.89">See Also</A></h2>

<P CLASS=para>
<A HREF="ch10_03.htm">Character</A>;
<A HREF="ch10_04.htm">Class</A>;
<A HREF="ch09_04.htm#JLR2-CH-9-SECT-4.1">Exceptions</A>;
<A HREF="ch10_10.htm">Integer</A>;
<A HREF="ch02_02.htm#JLR2-CH-2-SECT-2.3.1">Integer literals</A>;
<A HREF="ch03_01.htm#JLR2-CH-3-SECT-1.1.1">Integer types</A>;
<A HREF="ch10_13.htm">Number</A>;
<A HREF="ch10_20.htm">String</A>;
<A HREF="ch10_22.htm">System</A>

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch10_10.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch10_12.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>Integer</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>Math</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
